export default defineNuxtRouteMiddleware((to, from) => {
  if (process.client) {
    const toast = useToast()
    const router = useRouter()
    const hasLogin = !!(localStorage.getItem('token') && localStorage.getItem('userInfo'))
    if (hasLogin && (to.path === '/signin' || to.path === '/signup')) {
      toast.add({
        title: '已登录，正在进入',
        icon: 'i-heroicons-check-circle-solid',
        color: 'primary'
      })
      router.push('/')
    }
  }
})
